const Mock = require('mockjs')

Mock.setup({
  timeout: '200-600'
})

let configArray = []

const files = require.context('.', true, /\.js$/)
files.keys().forEach(key => {
  if (key === './index.js') {
    return
  }
  configArray = configArray.concat(files(key).default)
})

configArray.forEach(item => {
  for (const [path, data] of Object.entries(item)) {
    const protocol = path.split('|')
    const apiPath = protocol[1]
    const method = protocol[0]
    Mock.mock(apiPath, method, data)
  }
})
